package com.lz.struct;

/**
 * AdapterDemo..
 *
 * spring 在spring中的应用 https://blog.csdn.net/wwwdc1012/article/details/82780560
 *
 * @author Lizhong
 * @date 2019/9/26
 */
public class AdapterDemo {

    public static void main(String[] args) {
        // 播放音乐
    }

    interface IMusic {
        public void play();
    }

    class Mp3 implements IMusic {
        @Override
        public void play() {
            System.out.println("播放Mp3");
        }
    }


    // 目标接口，需要适配
    class Video {
        public void playVideo() {
            System.out.println("播放视频");
        }
    }

    // 适配器接口，
    interface Adapter {

    }

    /** 类的适配*/
    class VideoAdapter extends Video implements Adapter, IMusic {


        @Override
        public void play() {
            playVideo();
        }
    }

    /**对象适配*/
    class Abs implements Adapter, IMusic {
        private Video video;

        public Abs(Video video) {
            this.video = video;
        }

        @Override
        public void play() {
            video.playVideo();
        }
    }
}
